package com.yt.sys.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yt.sys.models.entity.SysRole;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SysRoleMapper extends BaseMapper<SysRole> {

    /**
     * 根据角色名称查找角色
     * @param roleName 角色名称
     * @return 角色信息
     */
    @Select("SELECT * FROM sys_role WHERE role_name = #{roleName} AND is_delete = 0 LIMIT 1")
    SysRole selectByRoleName(@Param("roleName") String roleName);

    /**
     * 获取所有未删除的角色
     * @return 角色列表
     */
    @Select("SELECT * FROM sys_role WHERE is_delete = 0 ORDER BY create_time DESC")
    List<SysRole> selectAllActive();
}